/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.action;

import com.dao.GradeDao;
import com.entity.Student;
import com.opensymphony.xwork2.ActionSupport;
import com.service.GradeQuery;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import org.apache.struts2.ServletActionContext;

/**
 *
 * @author DELL
 */
public class CourseGrade extends ActionSupport{
    
    
    
        private String page;
    
    public String getPage()
    {
        return page;
    }

    public void setPage(String page)
    {
        this.page = page;
    }
    
    
    public CourseGrade() {
    }
    
    public String execute() throws Exception {
        
         Logger.getLogger(this.getClass().getName()).log(Level.INFO, "aaaaaiiiiiiiiiiii11111111111111111111111111111111111");
        
                   HttpServletRequest request;
        request =ServletActionContext.getRequest();
                HttpSession session=request.getSession();
       
         Student st1=new Student();
   
         st1=(Student)session.getAttribute("student");
         
         Integer  stid=st1.getStId();
        
        
         
          
            int page2=0;
          if(this.page!=null){
          
       
              page2=Integer.parseInt(this.page);
          }  
               Logger.getLogger(this.getClass().getName()).log(Level.INFO, "xxxxxxxxxxxxxxxxx"+page2);
              
         GradeQuery gq=new GradeQuery();
         
          List gradeList=gq.getGrade(stid,page2);
         
         
//         
//           Logger.getLogger(this.getClass().getName()).log(Level.INFO, "aaaaaiiiiiiiiiiii11122222222222222222222222222211111");
//           GradeDao gradeDao=new GradeDao();
//           
//             List gradeList=gradeDao.getGrade(stid);


         session.setAttribute("gradeList", gradeList);
        
        return SUCCESS;
    }
    
    
    public String lastQuery() throws Exception {
    
    
                      HttpServletRequest request;
        request =ServletActionContext.getRequest();
                HttpSession session=request.getSession();
       
         Student st1=new Student();

         st1=(Student)session.getAttribute("student");
         
         Integer  stid=st1.getStId();
        
         
         
         int page2=(Integer)session.getAttribute("curPage")+1;
               
         
            Logger.getLogger(this.getClass().getName()).log(Level.INFO, "ttttttxxxxxxxxxxxxxxxxxxxxxx"+page2);
         
         GradeQuery gq=new GradeQuery();
         
          List gradeList=gq.getGrade(stid,page2);
         
         
//         
//           Logger.getLogger(this.getClass().getName()).log(Level.INFO, "aaaaaiiiiiiiiiiii11122222222222222222222222222211111");
//           GradeDao gradeDao=new GradeDao();
//           
//             List gradeList=gradeDao.getGrade(stid);


         session.setAttribute("gradeList", gradeList);
        
        return SUCCESS;
    
    }
    
    
    
    
}
